/*
* Copyright 2010 Pavel Kozhin 
*
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
* http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed  under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License.
*
* Author: Pavel Kozhin.
*/

package org.etherframework.dependency
{
	import flash.events.EventDispatcher;
	import flash.utils.Dictionary;
	import flash.utils.describeType;
	
	import mx.core.IMXMLObject;
	
	[Event(name="ready", type="flash.events.Event")]
	
	public class Beans extends EventDispatcher implements IMXMLObject
	{
		private var descriptor:XML;
		
		public function initialized(document:Object, id:String):void
		{
		}
		
		public function getItems():Dictionary
		{
			var result:Dictionary = new Dictionary();
			
			if (!descriptor)
				descriptor = describeType(this);
			
			var accessors:XMLList = descriptor.accessor.(@access == "readwrite").@name;
			var accessorsLen:int = accessors.length();
			var accessorName:String;
			
			for (var i:int = 0; i < accessorsLen; ++i) 
			{
				accessorName = accessors[i];
				
				if ((accessorName == "access") || (accessorName == "domain"))
					continue;
				
				result[accessorName] = this[accessorName];
			}
			
			return result;
		}
		
		private var _access:String = "local";
		
		[Inspectable(defaultValue="local", enumeration="local,hierarchical,@hierarchical,hierarchical@,global")]
		public function get access():String
		{
			return _access;
		}
		
		public function set access(value:String):void
		{
			_access = value;
		}
		
		private var _domain:String = "single";
		
		[Inspectable(defaultValue="single", enumeration="single,multiple")]
		public function get domain():String
		{
			return _domain;
		}
		
		public function set domain(value:String):void
		{
			_domain = value;
		}
		
	}
}